{* Smarty *}
{*
 *  This file is part of Urd.
 *
 *  Urd is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  Urd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. See the file "COPYING". If it does not
 *  exist, see <http://www.gnu.org/licenses/>.
 *
 * $LastChangedDate: 2008-07-12 15:43:11 +0200 (Sat, 12 Jul 2008) $
 * $Rev: 1291 $
 * $Author: gavinspearhead $
 * $Id: ajax_showtransfers.tpl 1291 2008-07-12 13:43:11Z gavinspearhead $
 *}
{* Ajax page, doesn't need a head/foot tpl *}
<br/>
<div id="globaldown" class="floatleft iconsize {if $transfer_hide_status.global == 1}dynimgplus{else}dynimgminus{/if} noborder buttonlike" onclick="javascript:fold_transfer('global', 'down');" alt="">
</div>
<div class="floatleft h3">&nbsp;{$LN_transfers_downloads}</div>

<table class="transfers {if $transfer_hide_status.global == 1}hidden{/if}" id="data_down_global">
<thead>
<tr class="head">
<th>{$LN_transfers_head_started}</th>
<th>{$LN_transfers_head_dlname}</th>
<th>{$LN_transfers_head_progress}</th>
<th>{$LN_size}</th>
<th>{$LN_transfers_head_username}</th>
<th>{$LN_transfers_head_speed}</th>
<th class="dltime">{$LN_eta}</th>
<th class="dlbuts">{$LN_transfers_head_options}</th>
</tr>
</thead>

{assign var="oldstatus" value=""}
{assign var="cnt" value="0"}

{foreach from=$infoarray item=a}

	{if $a->status == "ready"}	{assign var="status" value=$LN_transfers_status_ready}		{/if}
	{if $a->status == "active"}	{assign var="status" value=$LN_transfers_status_active}		{/if}
	{if $a->status == "finished"}	{assign var="status" value=$LN_transfers_status_finished}	{/if}
	{if $a->status == "cancelled"}	{assign var="status" value=$LN_transfers_status_cancelled}	{/if}
	{if $a->status == "paused"}	{assign var="status" value=$LN_transfers_status_paused}		{/if}
	{if $a->status == "stopped"}	{assign var="status" value=$LN_transfers_status_stopped}	{/if}
	{if $a->status == "shutdown"}	{assign var="status" value=$LN_transfers_status_shutdown}	{/if}
	{if $a->status == "error"}	{assign var="status" value=$LN_transfers_status_error}		{/if}
	{if $a->status == "complete"}	{assign var="status" value=$LN_transfers_status_complete}	{/if}
	{if $a->status == "rarfailed"}	{assign var="status" value=$LN_transfers_status_rarfailed}	{/if}
	{if $a->status == "par2failed"}	{assign var="status" value=$LN_transfers_status_par2failed}	{/if}
	{if $a->status == "cksfvfailed"}{assign var="status" value=$LN_transfers_status_cksfvfailed}	{/if}
	{if $a->status == "queued"}	{assign var="status" value=$LN_transfers_status_queued}		{/if}
	{if $a->status == "dlfailed"}	{assign var="status" value=$LN_transfers_status_dlfailed}	{/if}	
	{assign var="stat" value=$a->status|replace:' ':'_'}
	{if $oldstatus != $status}
		{if $cnt neq 0 }</tbody>{/if}
		<tbody><tr class="transferstatus"><td colspan="7">{$status}</td>
		<td>
		<div id="{$stat}down" class="floatright iconsize {if $transfer_hide_status.$stat == 1}dynimgplus{else}dynimgminus{/if} noborder buttonlike" onclick="javascript:fold_transfer('{$stat}', 'down');" alt="">
		</div>
		</td></tr></tbody>
		<tbody id="data_down_{$stat}" class="{if $transfer_hide_status.$stat == 1}hidden{/if}">
		{assign var="oldstatus" value=$status}
		{assign var="cnt" value="1"}
	{/if}
{capture name=bar assign="progressbar"}
{strip}
	<img src="{$IMGDIR}/left.png" height="12" width="2" alt="left"/>
	<img src="{$IMGDIR}/light.png" height="12" width="{$a->done}" alt="progressbar"/>
	<img src="{$IMGDIR}/dark.png" height="12" width="{$a->remain}" alt="progressbar"/>
	<img src="{$IMGDIR}/right.png" height="12" width="2" alt="right"/>
{/strip}
{/capture}

{capture name=prio assign="prio_button"}
{if $a->status == "queued" OR $a->status == "paused"}
	<a href=""><img src="{$IMGDIR}/icon_up.png" class="noborder" alt="Increase priority" onclick="javascript:TransferEdit('move_up','{$a->dlid}');"/></a>
	<a href=""><img src="{$IMGDIR}/icon_down.png" class="noborder" alt="Decrease priority" onclick="javascript:TransferEdit('move_down', '{$a->dlid}');"/></a>
{/if}
{/capture}

{capture name=opts assign="options"}
{strip}
{if $a->status == "rarfailed"}
<a href="{$a->directory}/rar.log"><img class="noborder" src="{$IMGDIR}/icon_badinfo.png" {popup text=$LN_transfers_badrarinfo } alt=""/></a>&nbsp;
{/if}
{if $a->status == "par2failed"}
<a href="{$a->directory}/par2.log"><img class="noborder" src="{$IMGDIR}/icon_badinfo.png" {popup text=$LN_transfers_badparinfo } alt=""/></a>&nbsp;
{/if}

<img class="buttonlike" onclick="ShowRenameTransfer('{$a->dlid}');" src="{$IMGDIR}/icon_edit.png" {popup text=$LN_transfers_linkedit } alt=""/>&nbsp;
<a href="{$a->linkview}"><img class="noborder" src="{$IMGDIR}/icon_folder.png" {popup text=$LN_transfers_linkview } alt=""/></a>
&nbsp;

{if ($a->status == "par2failed" or $a->status == "rarfailed" or $a->status == "finished") AND $urdd_online} 
<img class="buttonlike" onclick="TransferEdit('reparrar','{$a->dlid}')" src="{$IMGDIR}/icon_preview.png" {popup text=$LN_transfers_runparrar } alt=""/>&nbsp;
{else}
{/if}

{if ($a->status == "paused" OR $a->status == "ready") AND $urdd_online}
<img class="buttonlike" onclick="TransferEdit('start','{$a->dlid}')" src="{$IMGDIR}/icon_play.png" {popup text=$LN_transfers_linkstart } alt=""/>&nbsp;
{/if}

{if ($a->status == "active" OR $a->status == "queued" OR $a->status == "ready") AND $urdd_online}
<img class="buttonlike" onclick="TransferEdit('pause','{$a->dlid}')" src="{$IMGDIR}/icon_pause.png" {popup text=$LN_transfers_linkpause } alt=""/>&nbsp;
{/if}

{if ($a->status == "queued" OR $a->status == "paused" OR $a->status == "active"  OR $a->status == "ready") AND $urdd_online}
<img class="buttonlike" onclick="TransferEdit('cancel','{$a->dlid}')" src="{$IMGDIR}/icon_cancel.png" {popup text=$LN_transfers_linkcancel } alt=""/>&nbsp;
{/if}
{if $urdd_online}
<img class="buttonlike" onclick="TransferEdit('delete','{$a->dlid}')" src="{$IMGDIR}/icon_delete.png" {popup text=$LN_transfers_linkdelete } alt=""/>&nbsp;
{/if}

{/strip}
{/capture}

	<tr class="{cycle values="even,odd" name="cycle1"}">
		<td>{$a->startdate}</td>
		<td><b>{$a->name|truncate:$maxstrlen|escape:htmlall}</b>{$rename}</td>
		<td>{$progressbar} {$a->progress}</td>
		<td>{$a->size}</td>
		<td>{$a->username|escape:htmlall}</td>
		<td>{$a->speed}</td>
		<td class="dltime">{$a->ETA}</td>
		<td class="rightbut" colspan="2">{$prio_button} {$options}</td>
	</tr>
{/foreach}
</tbody>
</table>
<p>&nbsp;</p>

{if $poster neq 0 || $isadmin neq 0}
<div id="globalpost" class="floatleft iconsize {if $post_hide_status.global == 1}dynimgplus{else}dynimgminus{/if} noborder buttonlike" onclick="javascript:fold_transfer('global', 'post');" alt="">
</div>
<div class="floatleft h3">&nbsp;{$LN_transfers_posts}</div>
<table class="transfers {if $post_hide_status.global == 1}hidden{/if}" id="data_post_global">
<thead>
<tr class="head">
<th>{$LN_transfers_head_started}</th>
<th>{$LN_transfers_head_subject}</th>
<th>{$LN_transfers_head_progress}</th>
<th>{$LN_size}</th>
<th>{$LN_transfers_head_username}</th>
<th>{$LN_transfers_head_speed}</th>
<th class="dltime">{$LN_eta}</th>
<th class="dlbuts">{$LN_transfers_head_options}</th>
<th><div class="right"></div></th>
</tr>
</thead>

{assign var="oldstatus" value=""}
{assign var="status" value=""}
{assign var="cnt" value="0"}

{foreach from=$infoarray_upload item=a}
	{if $a->status == "ready"}	    {assign var="status" value=$LN_transfers_status_ready}		{/if}
	{if $a->status == "active"}	    {assign var="status" value=$LN_transfers_status_postactive}	{/if}
	{if $a->status == "finished"}	{assign var="status" value=$LN_transfers_status_finished}	{/if}
	{if $a->status == "cancelled"}	{assign var="status" value=$LN_transfers_status_cancelled}	{/if}
	{if $a->status == "paused"}	    {assign var="status" value=$LN_transfers_status_paused}		{/if}
	{if $a->status == "stopped"}	{assign var="status" value=$LN_transfers_status_stopped}	{/if}
	{if $a->status == "shutdown"}	{assign var="status" value=$LN_transfers_status_shutdown}	{/if}
	{if $a->status == "error"}	    {assign var="status" value=$LN_transfers_status_error}		{/if}
	{if $a->status == "rarred"}	    {assign var="status" value=$LN_transfers_status_rarred}	    {/if}
	{if $a->status == "par2ed"}	    {assign var="status" value=$LN_transfers_status_par2ed}	    {/if}
	{if $a->status == "yyencoded"}  {assign var="status" value=$LN_transfers_status_yyencoded}	{/if}
	{if $a->status == "queued"}	    {assign var="status" value=$LN_transfers_status_queued}		{/if}
	{if $a->status == "rarfailed"}	{assign var="status" value=$LN_transfers_status_rarfailed}	{/if}
	{if $a->status == "par2failed"}	{assign var="status" value=$LN_transfers_status_par2failed}	{/if}
	{if $a->status == "yyencodefailed"} {assign var="status" value=$LN_transfers_status_yyencodefailed}	{/if}
	{assign var="stat" value=$a->status|replace:' ':'_'}
	{if $oldstatus != $status}
		{if $cnt neq 0 }</tbody>{/if}
		<tbody><tr class="transferstatus"><td colspan="8">{$status}</td>
		<td>
		<div id="{$stat}post" class="floatright iconsize {if $post_hide_status.$stat == 1}dynimgplus{else}dynimgminus{/if} noborder buttonlike" onclick="javascript:fold_transfer('{$stat}', 'post');" alt="">
		</td></tr></tbody>
		<tbody id="data_post_{$stat}" class="{if $post_hide_status.$stat == 1}hidden{/if}">
		{assign var="oldstatus" value=$status}
		{assign var="cnt" value="1"}
	{/if}
{capture name=bar assign="progressbar"}
{strip}
	<img src="{$IMGDIR}/left.png" height="12" width="2" alt="left"/>
	<img src="{$IMGDIR}/light.png" height="12" width="{$a->done}" alt="progressbar"/>
	<img src="{$IMGDIR}/dark.png" height="12" width="{$a->remain}" alt="progressbar"/>
	<img src="{$IMGDIR}/right.png" height="12" width="2" alt="right"/>
{/strip}
{/capture}


{capture name=opts assign="options"}
{strip}
{if $a->status == "rarfailed"}
<a href="{$a->directory}/rar.log"><img class="noborder" src="{$IMGDIR}/icon_badinfo.png" {popup text=$LN_transfers_badrarinfo } alt=""/></a>&nbsp;
{/if}
{if $a->status == "par2failed"}
<a href="{$a->directory}/par2.log"><img class="noborder" src="{$IMGDIR}/icon_badinfo.png" {popup text=$LN_transfers_badparinfo } alt=""/></a>&nbsp;
{/if}
<img class="buttonlike" onclick="ShowEditPost('{$a->postid}');" src="{$IMGDIR}/icon_edit.png" {popup text=$LN_transfers_linkedit } alt=""/>&nbsp;

{if ($a->status == "paused" OR $a->status == "ready") AND $urdd_online}
<img class="buttonlike" onclick="post_edit('start','{$a->postid}')" src="{$IMGDIR}/icon_play.png" {popup text=$LN_transfers_linkstart } alt=""/>&nbsp;
{/if}

{if ($a->status == "active" OR $a->status == "queued" OR $a->status == "ready") AND $urdd_online}
<img class="buttonlike" onclick="post_edit('pause','{$a->postid}')" src="{$IMGDIR}/icon_pause.png" {popup text=$LN_transfers_linkpause } alt=""/>&nbsp;
{/if}

{if ($a->status == "queued" OR $a->status == "paused" OR $a->status == "active"  OR $a->status == "ready") AND $urdd_online}
<img class="buttonlike" onclick="post_edit('cancel','{$a->postid}')" src="{$IMGDIR}/icon_cancel.png" {popup text=$LN_transfers_linkcancel } alt=""/>&nbsp;
{/if}
{if $urdd_online}
<img class="buttonlike" onclick="post_edit('delete','{$a->postid}')" src="{$IMGDIR}/icon_delete.png" {popup text=$LN_transfers_linkdelete } alt=""/>&nbsp;
{/if}
{/strip}
{/capture}

	<tr class="{cycle values="even,odd" name="cycle1"}">
		<td>{$a->startdate}</td>
		<td><b>{$a->name|truncate:$maxstrlen|escape:htmlall}</b>{$rename}</td>
		<td>{$progressbar} {$a->progress}</td>
		<td>{$a->size}</td>
		<td>{$a->username|escape:htmlall}</td>
		<td>{$a->speed}</td>
		<td class="dltime">{$a->ETA}</td>
		<td class="rightbut" colspan="2">{$prio_button} {$options}</td>
	</tr>
{/foreach}
</tbody>

</table>
{/if}


<input type="hidden" name="challenge" id="challenge2" value="{$challenge}"/>
<input type="hidden" name="urdd_message" id="urdd_message" value="{$offline_message}"/>
<input type="hidden" name="urdd_status" id="urdd_status" value="{$urdd_online}"/>
